<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thyemleaf.org">
<head>

    <meta charset="UTF-8">

    <!--BootStrap设计的页面支持响应式的 -->

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- 引入主题  -->

    <link href="/bootstrap-3.3.7/css/bootstrap-theme.min.css" rel="stylesheet" />

    <!-- 引入bootstrap的css -->

    <link href="/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet" />

    <!-- 引入jquery的js  因为bootstrap使用到jquery的js -->

    <script src="/js/jquery-3.3.1.min.js"></script>

    <!-- 引入bootsrap的js -->

    <script src="/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <!--    进度条-->
    <link rel="stylesheet" href="/blue/pace-theme-corner-indicator.css">
    <script src="js/pace.js"></script>
<!--magic布局-->
    <link href="https://cdn.bootcss.com/Chart.js/2.8.0/Chart.css" rel="stylesheet">

    <title>商品详情</title>
    <style>
        .xiaotaoobject {
            height: 140px;
            width: 140px;
            object-fit: contain;
        }
        .samesize{
            height: 320px ;
            width: 100%;
            object-fit: cover;
            text-align: center;
        }
        .samesizesmall{
            height: 250px;
            max-width: 100% ;
            object-fit: cover;
            text-align: center;
        }
        body{
            background-image: url("images/背景.jpg");
        }
    </style>

</head>
<body >
<div class="container">
    <div class="row clearfix">
        <div class="col-md-6 column">
            <div class="row clearfix">
                <div class="col-md-6 column">
                    <img alt="小淘图标" class="xiaotaoobject"  src="images/order_a.jpg" />
                </div>
                <div class="col-md-6 column">
                    <div class="page-header">
                        <h1>
                            小淘商城<p><small>2020最新潮流</small></p>
                        </h1>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-6 column">
            <ul class="breadcrumb">
                <li>
                    <a href="#">首页</a>
                </li>
                <li class="active">
                    数据分析
                </li>
            </ul>
            <blockquote>
                <p >
                    <span class="glyphicon glyphicon-bell">
                    您的每一分努力都会被看到
                    </span>
                </p> <small> <cite>小淘寄语</cite></small>
            </blockquote>
        </div>
    </div>
<!--柱形图-->

    <div style="width:600px; margin-top: 120px;margin-left:320px;">
        <canvas id="myChart" width="600" height="300"></canvas>
    </div>
    <script src="https://cdn.bootcss.com/Chart.js/2.8.0/Chart.js"></script>
    <script th:inline="javascript">
        var goods=[[${goods}]];
        var l= new Array();
        let d = new Array();
        var backColor= new Array();
        var borColor=new Array();
        for( var i=0;i<goods.length;i++)
        {
            l.push(goods[i].item_name);
            d.push(goods[i].sell_num);
            backColor.push('rgba('+Math.ceil(Math.random()*255)+','+Math.ceil(Math.random()*255)+','+Math.ceil(Math.random()*255)+',0.2)');
            borColor.push('rgba('+Math.ceil(Math.random()*255)+','+Math.ceil(Math.random()*255)+','+Math.ceil(Math.random()*255)+',1)');

        }

        var ctx = document.getElementById('myChart').getContext('2d');
        var myChart = new Chart(ctx, {
            type: 'bar',   //  线形图：line、条形图：bar 、雷达图：radar、馅饼和甜甜圈图表：pie、极区面积图：polarArea、汽泡：bubble
            data: {
                labels: l,
                datasets: [{
                    label: '商品总销量',
                    data: d,
                    backgroundColor: backColor,
                    borderColor:borColor,
                    borderWidth: 1
                }]
            },
            options: {
                scales: {
                    yAxes: [{
                        ticks: {
                            beginAtZero: true
                        }
                    }]
                }
            }
        });
    </script>


</div>

</body>
</html>